﻿using System.Net.Sockets;
using Letter.Net.Extensions;

namespace Letter.Net.Udp;

static class UdpHostFeatureSetting
{
    public static void SettingFeature(Socket socket, UdpHostFeatureOptions feature)
    {
        if (feature.RcvTimeout != null)
        {
            socket.SettingRcvTimeout(feature.RcvTimeout.Value);
        }

        if (feature.SndTimeout != null)
        {
            socket.SettingSndTimeout(feature.SndTimeout.Value);
        }

        if (feature.RcvBufferSize != null)
        {
            socket.SettingRcvBufferSize(feature.RcvBufferSize.Value);
        }

        if (feature.SndBufferSize != null)
        {
            socket.SettingSndBufferSize(feature.SndBufferSize.Value);
        }
        
        if (feature.Linger != null)
        {
            socket.SettingLingerState(feature.Linger);
        }
    }
}